package com.cty.service.impl;

import com.cty.mapper.ShopReviewMapper;
import com.cty.pojo.ShopReview;
import com.cty.service.ReviewService;
import com.cty.util.ServerResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ReviewServiceImpl implements ReviewService {
    @Autowired
    private ShopReviewMapper reviewMapper;

    @Override
    public ServerResult save(ShopReview review) {
      int rows =   reviewMapper.insert(review);
        return  rows>0?ServerResult.saveSuccess(null):ServerResult.saveFail(null);
    }
    @Override
    public ShopReview getById(Integer reviewId) {
        return reviewMapper.selectByPrimaryKey(reviewId);
    }

    @Override
    public ShopReview update(ShopReview shopReview) {
        System.out.println("review service  , shopReview:" + shopReview);
        int rows = reviewMapper.updateByPrimaryKeySelective(shopReview);
        if(rows >0){
            System.out.println("mysql  修改当前评论点赞数成功");
        }
        return shopReview;
    }
}
